/* tcpbind.c - tcpbind */

#include <netdb.h>

#include "tcpfms.h"
#include "tcb.h"
#include "port.h"
#include "tcp.h"
#include "defines.h"


//verificar
/*------------------------------------------------------------------------
 *  tcpbind - bind a TCP pseudo device to its addresses and port
 *------------------------------------------------------------------------
 */
int tcpbind(struct tcb *ptcb, ipaddr fip, u_short fport)
{
    //if (dnparse(fport, &ptcb->tcb_rip, &ptcb->tcb_rport) == SYSERR)
    //    return SYSERR;

    ptcb->tcb_lip = get_local_ip();
    ptcb->tcb_rip = fip;
    ptcb->tcb_lport = newport(0, TCPQLEN);
    ptcb->tcb_rport = fport;
    
    return ptcb->tcb_lport > 0;
}